package lab03.test09;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by V555 on 2017/12/19.
 */
public class Test {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        String path="D:\\book.txt";
        File bookInformation=new File(path);
        try {
            bookInformation.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        BufferedReader reader=null;
        BufferedWriter writer=null;
        try {
            reader=new BufferedReader(new FileReader("D:\\b.txt"));
            writer=new BufferedWriter(new FileWriter("D:\\book.txt"));
            while (true){
                String line=reader.readLine();
                if (line==null){
                    break;
                }else {
                    String[] strings=line.split(" ");
                    for (int i=0;i<strings.length;i++){
                        list.add(strings[i]);
                    }
                }
            }
            for (int i=0;i<list.size();i++){
                if (list.get(i).equals("29.8")){
                    writer.write("59.8");
                    writer.write("      ");
                }else if (list.get(i).equals("42.5")){
                    writer.write("62.5");
                    writer.write("      ");
                }else {
                    writer.write(list.get(i));
                    writer.write("      ");
                    if (i%5==0){
                        writer.newLine();
                    }
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            try {
                reader.close();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
